package behaviorpattern.observer;

/**
 * BinaryObserver
 *
 * @author seer
 * @date 2018/2/7 15:35
 */
public class BinaryObserver extends Observer {
    public BinaryObserver(Subject subject) {
        this.subject = subject;
        this.subject.attach(this);
    }

    @Override
    void update() {
        System.out.printf("this message from %s[%s]#%s\n",
                Thread.currentThread().getStackTrace()[1].getClassName(),
                Thread.currentThread().getStackTrace()[1].getLineNumber(),
                Thread.currentThread().getStackTrace()[1].getMethodName());
        System.out.println(this.getClass().getName() + subject.getState());
    }
}
